<template>
  <section class="goods-status section">
    <h2 class="section-tit">
      <span>商品动态</span>
      <span>交易动态</span>
    </h2>
    <div class="content-wrap clearfix">
      <div class="content-item-wrap col-sm-6">
        <div class="item sale">
          <router-link to="/goods/sale">
            <i><em v-if="goods.onSaleNum">{{returnNumber(goods.onSaleNum)}}</em></i>
            <p>出售中商品</p>
          </router-link>
        </div>
        <div class="item store">
          <router-link to="/goods/store">
            <i><em v-if="goods.inStoreHouseNum">{{returnNumber(goods.inStoreHouseNum)}}</em></i>
            <p>仓库中商品</p>
          </router-link>
        </div>
        <div class="item out">
          <router-link to="goods/pulled">
            <i><em v-if="goods.illegalDeliveryNum">{{returnNumber(goods.illegalDeliveryNum)}}</em></i>
            <p>违规下架商品</p>
          </router-link>
        </div>
      </div>
      <div class="content-item-wrap col-sm-6">
        <div class="item wait">
          <router-link to="/order">
            <i><em v-if="order.pendingPaymentNum">{{returnNumber(order.pendingPaymentNum)}}</em></i>
            <p>待付款订单</p>
          </router-link>
        </div>
        <div class="item send">
          <router-link to="/order/delivery">
            <i><em v-if="order.pendingShipmentNum">{{returnNumber(order.pendingShipmentNum)}}</em></i>
            <p>待发货订单</p>
          </router-link>
        </div>
        <div class="item refund">
          <router-link to="/order/refund">
            <i><em v-if="order.refundOrderNum">{{returnNumber(order.refundOrderNum)}}</em></i>
            <p>退款订单</p>
          </router-link>
        </div>
      </div>
    </div>
  </section>
</template>

<script>
  export default {
    props: {
      goods: {
        type: Object,
        default: () => { return {} }
      },
      order: {
        type: Object,
        default: () => { return {} }
      }
    },
    methods: {
      /**
       * 展示数值
       * @param  { Number } number 数值
       */
      returnNumber(number) {
        // 如果数值在99以内
        if (number <= 99) {
          return number
        }
        // 如果超过99
        return '99+'
      }
    }
  }
</script>

<style lang="scss" scoped>
  @import './style.scss';
</style>